<?php
/**
 * @version $Id: view.html.php 48 2011-09-28 06:47:49Z lnmtrung $
 */
 
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.application.component.view' );

class WrdViewEducation extends WrdView{
	
	function display($tpl = null) {
		
		$this->setModel($this->getModel('education'), true);
		$fnc = 'display'.ucfirst($this->getLayout());
		if (is_callable(array(&$this, $fnc)))
			$this->$fnc($tpl);
		else
			parent::display($tpl);
	}

	function displayDefault($tpl = null){
		
		$mainframe = &JFactory::getApplication();
		$context = JRequest::getCmd('option');
		$view = JRequest::getCmd('view');
		
		$document = & JFactory::getDocument();
		$document->setTitle( JText::_('Education Manager') );

		JToolBarHelper::title(JText::_('Education Manager'),'education.png');
 		JToolBarHelper::addNew();
 		JToolBarHelper::publish();
 		JToolBarHelper::unpublish();
		JToolBarHelper::deleteList();
		
		WrdHelper::addSubMenu('config',$view);
		$this->sidebar = JHtmlSidebar::render();

		$filter_order     		= $mainframe->getUserStateFromRequest( $context.$view.'filter_order_item','filter_order','id' );
		$filter_order_Dir 		= $mainframe->getUserStateFromRequest( $context.$view.'filter_order_Dir','filter_order_Dir', '' );

		$lists['order'] 		= $filter_order;
		$lists['order_Dir'] 	= $filter_order_Dir;
		
		$items					= & $this->get( 'Data');
				
		$total					= & $this->get( 'Total');
		$pagination 			= & $this->get( 'Pagination' );
		 
		$search 				= $mainframe->getUserStateFromRequest( $context.$view.'search','search','','string' );
		$filter_state 			= $mainframe->getUserStateFromRequest( $context.$view.'published','published',-1,'int' );
		$filter_user			= $mainframe->getUserStateFromRequest( $context.$view.'created_id','created_id',-1,'int' );
		
		$search 				= JString::strtolower( $search );
		
		$lists['search'] 		= $search;
		$lists['published'] 	= JHTML::_('wrd.published',$filter_state,'onchange="this.form.submit()"');
		$lists['user'] 			= JHTML::_('wrd.listUser','created_id',$filter_user,'onchange="this.form.submit()"','education');
		
	    $this->assignRef('search',		$search);
	    $this->assignRef('lists',		$lists);
	  	$this->assignRef('items',		$items);
	    $this->assignRef('pagination',	$pagination);
	    
	    parent::display($tpl);
  	}
  
  	function displayForm($tpl = null){
		$mainframe = &JFactory::getApplication();
		$context = JRequest::getCmd('option');
		$view = JRequest::getCmd('view');
		$user = JFactory::getUser();
		$cid = JRequest::getInt('id');
		$model	=& $this->getModel();
		
		$detail = array();
		if($cid != 0)
		{
			$detail	=& $model->getItem($cid);
		}
		
		//$isNew	= ($detail->id < 1);
		$lists = array();
		$lists['published'] 		= JHTML::_('wrd.published',$detail->published,'',0 );
		
		$text = ($detail->id < 1) ? JText::_( 'NEW' ) : JText::_( 'EDIT' );
		JToolBarHelper::title(   JText::_( 'Department' ).': <small><small>['.$text.']</small></small>','education.png' );
		JToolBarHelper::save();
		JToolBarHelper::cancel( 'cancel', 'Close' );

		$this->assignRef('data',	$detail);
		$this->assignRef('lists',	$lists);
		$this->assignRef('user',	$user);
		parent::display($tpl);
	}
}
?>